package com.cmower.baeldung.arrays1;

import java.util.Arrays;
import java.util.Comparator;

public class SortDemo {
    public static void main(String[] args) {
        int[] anArray = new int[] {5, 2, 1, 4, 8};
        Arrays.sort(anArray); // anArray is now {1, 2, 4, 5, 8}
        System.out.println(Arrays.toString(anArray));

        Integer[] anotherArray = new Integer[] {5, 2, 1, 4, 8};
        Arrays.sort(anotherArray); // anotherArray is now {1, 2, 4, 5, 8}


        String[] yetAnotherArray = new String[] {"A", "E", "Z", "B", "C"};
        Arrays.sort(yetAnotherArray, 1, 3,
                Comparator.comparing(String::toString).reversed()); // yetAnotherArray is now {"A", "Z", "E", "B", "C"}
        System.out.println(Arrays.toString(yetAnotherArray));
    }
}
